package com.ijuit.validate;

import com.ijuit.common.kit.StringKit;
import com.ijuit.model.user.User;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * 用户注册校验类
 * 
 * @author 罗龙
 *
 */
public class RegisterValidator extends Validator{

	@Override
	protected void validate(Controller c) {
		validateRequiredString("user.loginId", "loginIdMsg", "请输入登陆账号！");
		validateRequiredString("user.password", "passwordMsg", "请输入密码！");
		validateRequiredString("user.mobileTelephone", "mobileTelephoneMsg", "请输入手机号！");
		if(StringKit.notBlank(c.getPara("user.email"))) {
			validateEmail("user.email", "emailMsg", "邮箱格式错误！");
		}
	}

	@Override
	protected void handleError(Controller c) {
		c.keepModel(User.class);
	}

}
